package org.agiba.jira.plugin;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.Map;

import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.client.XmlRpcClient;
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;

public class RawXmlRpc
{
   public static void main(String[] args)
       throws MalformedURLException, XmlRpcException
   {
        XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
		URL url = new URL("http://localhost:8080/xwiki/xmlrpc");
        config.setServerURL(url);
        XmlRpcClient client = new XmlRpcClient();
        client.setConfig(config);
       
        String token = (String)client.execute("confluence1.login",
           new Object[] {"Admin", "admin"});
       
		Map page = (Map) client.execute("confluence1.getPages", new Object[] {
				token, "Main" });
        String pageId = (String)page.get("id");
        String content = (String)page.get("content");
       
        String renderedContent = (String)client.execute(
           "confluence1.renderContent",
           new Object[] {token, "Main", pageId, content});
        System.out.print(renderedContent);
   }
}